﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using CloudSyncLib.Tasks;
using CloudSyncLib.Storages;

namespace CloudSyncTests
{
    [TestClass]
    public class DatabaseBackupTest
    {
        [TestMethod]
        public void Backup()
        {

            DatabaseBackupTask task = new DatabaseBackupTask();

            task.ZipPassword = "CF33BF2F-3A33-48FE-BF3E-CD612A59B09F";

            task.BackupFolder = "d:\\BackupTests";
            task.IgnoreDatabases = "master,tempdb,model,msdb,ReportServer,ReportServerTempDB";
            task.ConnectionString = new System.Data.SqlClient.SqlConnectionStringBuilder();
            task.ConnectionString.DataSource = "(local)";
            task.ConnectionString.UserID = "sa";
            task.ConnectionString.Password = "$abcd123";

            AzureStorage storage = new AzureStorage();
            storage.Container = "test";
            storage.Host = "casting800test.blob.core.windows.net";
            storage.Key = "casting800test";
            storage.Secrete = "Ye6sL8qDjU4JMJVybNLPVXy46kwy1C5W1pLAEKqdkBs0JBTZQP6KzM2hl5ytgHLmdBJ7hDgfNKQ0a9wAzWZzgg==";
            task.Storage = storage;
            task.Run();

        }

        [TestMethod]
        public void Restore() 
        {
            DatabaseRestoreTask task = new DatabaseRestoreTask();
            task.ZipPassword = "CF33BF2F-3A33-48FE-BF3E-CD612A59B09F";
            task.BackupFolder = "d:\\BackupTests";
            task.IgnoreDatabases = "master,tempdb,model,msdb,ReportServer,ReportServerTempDB";
            task.ConnectionString = new System.Data.SqlClient.SqlConnectionStringBuilder();
            task.ConnectionString.DataSource = "(local)";
            task.ConnectionString.UserID = "sa";
            task.ConnectionString.Password = "$abcd123";

            AzureStorage storage = new AzureStorage();
            storage.Container = "test";
            storage.Host = "casting800test.blob.core.windows.net";
            storage.Key = "casting800test";
            storage.Secrete = "Ye6sL8qDjU4JMJVybNLPVXy46kwy1C5W1pLAEKqdkBs0JBTZQP6KzM2hl5ytgHLmdBJ7hDgfNKQ0a9wAzWZzgg==";
            task.Storage = storage;
            task.Run();
        }

    }
}
